<?php
namespace app\admin\controller;
use think\Controller;
use app\admin\Model\Yuyue as Yu;
use app\admin\Model\Number;
use app\admin\Model\Pay;
use think\Db;
class Yuyue extends Common
{
	
	public function list(){
		$yu = new Yu();
		$list = Yu::with('number')->with('rom')->paginate(4);
		$page = $list->render();
	  
		//halt($list);
		return $this->fetch('list',['list'=>$list,'page'=>$page]);
	}
	public function add(){
		
		$yu = new Yu();
		if(input("?param.sub")){
			
			$result = $yu->add();
			
			if($result){
				$this->success("添加成功","yuyue/list");
			}else{
				$this->error("添加失败");
			}
		}else{
			//$data  = \app\index\model\Class1::getList();
			
			$pay = new Pay();
			$list1 = Pay::all();
			//halt($list1);
			$num = new Number();
			$list = Number::all();
			$this->assign('list1',$list1);
			$this->assign('list',$list);
			return $this->fetch();
		}
	}
	
	public function list1(){
	    $data = Db::table('house_rom')->where('n_id',input('param.r_id'))->select();
	    
	    return json($data);
    }
    public function chuli(){
    	$yu = new Yu();
		
		if(input("?param.sub")){
			
			$result = $yu->upd();
			//dump($result);
			//exit;
			if($result){
				$this->success("修改成功","yuyue/list");
			}else{
				$this->error("修改失败");
			}
		}else{
			
			
		$id = input('param.z_id');
    	
    	$data = Yu::get($id);
    	//halt($data);
    	
    	$this->assign('data',$data);
    	
        return $this->fetch();
		}
    }
}
?>